//
//  Advert.m
//  AoA
//
//  Created by abaca on 2010/9/13.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Advert.h"


static NSString *kCname   = @"cname";
static NSString *kTeacher = @"teacher";
static NSString *kCdate   = @"cdate";
static NSString *kCtime   = @"ctime";
static NSString *kFee     = @"fee";
static NSString *kAddress = @"address";
static NSString *kRemark  = @"remark";
static NSString *kContact = @"contact";
static NSString *kEmail   = @"email";

@implementation Advert

@synthesize theData;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];

	/*
	UITextField *txt = [[[UITextView alloc] initWithFrame:self.view.frame] autorelease];
	txt.text = [NSString stringWithFormat:@"%@ \n%@ \n%@",
		[self.theData objectForKey:kCname],
		[self.theData objectForKey:kTeacher],
		[self.theData objectForKey:kCdate]];
	
	// this will cause automatic vertical resize when the table is resized
	txt.autoresizingMask = UIViewAutoresizingFlexibleHeight;
	
	// note: for UITextView, if you don't like autocompletion while typing use:
	// myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
	
	[self.view addSubview:txt];
	*/
	
	UIWebView *myWebView = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease];
	myWebView.backgroundColor = [UIColor whiteColor];
	myWebView.scalesPageToFit = YES;
	myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	//myWebView.delegate = self;

	NSString* detailmesssage = [NSString stringWithFormat:
							 @"<html><div style='font-size: 38pt;'>%@</div1><br/>"
							   "<table border='1' style='font-size: 36pt;border-collapse: collapse;' bordercolor='#9e9e9e'>"
							   "<tr><td noWrap>授課老師 :&nbsp;</td><td style='font-weight:bold;'>%@</td></tr>"
							   "<tr valign=top><td noWrap>日　　期 :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "<tr valign=top><td noWrap>時　　間 :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "<tr valign=top><td noWrap>費　　用 :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "<tr valign=top><td noWrap>上課地點 :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "<tr valign=top><td noWrap>其他說明 :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "<tr valign=top><td noWrap>連絡人 :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "<tr valign=top><td noWrap>email :&nbsp;</td><td>&nbsp;%@&nbsp;</td></tr>"
							   "</table></html>",
							 [self.theData objectForKey:kCname],
							 [self.theData objectForKey:kTeacher],
							 [self.theData objectForKey:kCdate],
						 	 [self.theData objectForKey:kCtime],
							 [self.theData objectForKey:kFee],
							 [self.theData objectForKey:kAddress],
							 [self.theData objectForKey:kRemark],
							 [self.theData objectForKey:kContact],
							 [self.theData objectForKey:kEmail]];
	[myWebView loadHTMLString:detailmesssage baseURL:nil];
	[self.view addSubview: myWebView];
	
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
	theData = nil;
}


- (void)dealloc {
	[theData release];
    [super dealloc];
}


@end
